<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="$!webPath/css/template.css"  rel="stylesheet" type="text/css"/>
    <script src="$!webPath/js/jquery-1.6.2.js"></script>
    <script src="$!webPath/js/jquery.shop.common.js"></script>
</head>
<body>
<div class="header_nav">
    <iframe name="content_frame" src="$!webPath/admin/nav" marginwidth=0 marginheight=0  frameborder=0 width=100% height=80/></iframe>
    <div class="cont_right"><a href="$!webPath/login">注销</a></div>
</div>
<form name="ListForm" id="ListForm" method="post" action="$!webPath/admin/.htm">
    <div class="cont">
        <h3 class="seth">管理员列表</h3>
        <div class="nav_list">
            <ul>
                <li><a href="$!webPath/admin/admin_list?size=10&page=0"  class="this"><b>管理员列表</b></a></li>
                <li><a href="$!webPath/admin/admin_add"><b>管理员新增</b></a></li>
            </ul>
        </div>
        <div class="fshoptb">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="fshop_table">
                <tr>
                    <th width="">
                        <span class="form_btna">用户名</span>
                    </th>
                    <th width="">
                        <span class="form_btna">手机</span>
                    </th>
                    <th width="">
                        <span class="form_btna">类型</span>
                    </th>
                    <th width="" align="center"><span class="form_btna">最后登录时间</span></th>
                    <th width="" align="center"><span class="form_btna">创建时间</span></th>
                    <th width="" align="center"><span class="form_btna">更新时间</span></th>
                    <th width="" align="center"><span class="form_btna">创建者</span></th>
                    <th width="" align="center"><span class="form_btna">更新者</span></th>
                    <th width="" align="center"><span class="form_btna">状态</span></th>
                    <th align="center" width=""><b class="form_btnb">操作</b></th>
                </tr>
                <tbody id="adminUsers">
                #foreach($obj in $!adminUsers)
                <tr id="$!obj.id">
                    <td align="center">$!obj.userName</td>
                    <td align="center">$!obj.mobile</td>
                    <td align="center">$!obj.userType</td>
                    <td align="center">$!CommUtil.formatLongDate($!obj.lastLoginDate)</td>
                    <td align="center">$!obj.createdAt</td>
                    <td align="center">$!obj.updateAt</td>
                    <td align="center">$!obj.createdBy</td>
                    <td align="center">$!obj.updateBy</td>
                    #if($!obj.userStatus==1)
                    <td align="center">正常</td>
                    #else
                    <td align="center">异常</td>
                    #end
                    <td align="center" class="hui oprate_con">
                        <a href="$!webPath/admin/admin_add?adminUserId=$!obj.id" class="blue">编辑</a>
                        <a href="#" onclick="return admin_del('$!obj.id')" class="blue">删除</a>
                    </td>
                </tr>
                #end
                </tbody>
            </table>
            <span id="spanFirst">第一页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span>
        </div>
    </div>

    <div class="operate_bar">
        <div class="fenye">
            <input name="userRole" type="hidden" id="userRole" value="ADMIN" />
            <input type="hidden" name="currentPage" id="currentPage" value="$!currentPage" />
            <input name="mulitId" type="hidden" id="mulitId" />
            $!gotoPageFormHTML
        </div>
    </div>
</form>
<script>

    getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }


    //替换指定传入参数的值,paramName为参数,replaceWith为新值
    function replaceParamVal(paramName,replaceWith) {
        var oUrl = this.location.href.toString();
        var re=eval('/('+ paramName+'=)([^&]*)/gi');
        var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
        this.location = nUrl;
    }
    var pageSize = getUrlParam('size');
    var page = getUrlParam('page');
    $('#spanFirst').click(function () {
        page=0;
        $.ajax({
            url:'$!webPath/admin/admin_list?size=10&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/admin_list?size=10&page='+page;
                replaceParamVal('page',page);
            }
        })
    })
    $('#spanNext').click(function(){
        page++;
        $.ajax({
            url:'$!webPath/admin/admin_list?size=10&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/admin_list?size=10&page='+page;
                replaceParamVal('page',page);
            }
        })
    })

    $('#spanPre').click(function(){
        page--;
        if(page<=0){
            page=0;
        }
        $.ajax({
            url:'$!webPath/admin/admin_list?size=10&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/admin_list?size=10&page='+page;
                replaceParamVal('page',page);
            }
        })
    })
    function admin_del(id){
        if(confirm("你确定要删除吗？")){
            $.ajax({
                url:'$!webPath/admin/delete_admin_user?adminId='+id,
                type:'delete',
                success: function () {
                    $('#'+id).remove();
                    window.location.reload();
                },
                error:function(){
                    alert('删除失败');
                }
            })
        }
    }
</script>
</body>
</html>
